#ifndef BASE_FDMAP_HPP
#define BASE_FDMAP_HPP

#include <base/defines.h>
#include <string>
#include <mutex>
#include <unordered_map>

class FdMap {
    public:
        static FdMap* GetInstance();
        void SetFdMap(int fd, const std::string& name);
        void DelFdMap(int fd);
        std::string FindFdMap(int fd);
        NONCOPYABLE(FdMap);
        IMMOVEABLE(FdMap);
    private:
        FdMap();
        void InitFdMap();
        ~FdMap();
    private:
        std::unordered_map<int, std::string> fdmap_;
        std::mutex fd_map_mutex_;
        static FdMap* instance_;
        static std::mutex mutex_;
};


#endif